# -*- coding: utf-8 -*-
class ClaimReturned < ActiveRecord::Base
  has_many :claim_returned_details,:dependent => :destroy  #级联删除子表

  belongs_to :warehouse
  belongs_to :employee
  belongs_to :department
  belongs_to :company
  belongs_to :claim
  belongs_to :warehousing_entry
  belongs_to :purchase_order
  belongs_to :logistics

  def self.countAllClaimReturneds  conditionsStr,conditionsHash
    begin
      count(
        :all,
        :conditions => [conditionsStr,conditionsHash]
      )
    rescue Exception => e
      logger.info e
    end
  end

  def self.findAllClaimReturneds  conditionsStr,conditionsHash,paramsHash
    begin
      find(
        :all,
        :conditions => [conditionsStr,conditionsHash],
        :include => [:logistics,:purchase_order,:warehousing_entry,:department,:employee,:warehouse,:claim],
        :offset => paramsHash[:offset],
        :limit => paramsHash[:limit],
        :order => 'claim_returneds.updated_at DESC'
      )
    rescue Exception => e
      logger.info e
    end
  end
end
